﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;

namespace AcfunUpload
{
    public partial class Upload : Form
    {
        public Upload()
        {
            InitializeComponent();
        }
        private string _selectFilePath = "";

        private void btnSelectFile_Click(object sender, EventArgs e)
        {
            string file = odlgFile.FileName;
            odlgFile.ShowDialog();
            if (file != odlgFile.FileName)
            {
                file = odlgFile.FileName;
                _selectFilePath = file;
                lblFilePath.Text = "选择文件：" + odlgFile.SafeFileName;
            }
        }

        private void btnSelectPic_Click(object sender, EventArgs e)
        {
            string file = odlgPic.FileName;
            odlgPic.ShowDialog();
            if (file != odlgPic.FileName)
            {
                file = odlgPic.FileName;
                picCover.Image = Image.FromFile(file);
            }
        }

        private void Upload_Load(object sender, EventArgs e)
        {
            /*string path = @"E:\video\anime\lib\【电影】你的名字 Your Name\你的名字.mp4";
            string newPath = Video.copyFile(path);
            VideoTime vt = Video.getVideoTime(newPath);
            Video.dividedVideo(newPath, vt);*/
        }

        private void btnToggle_Click(object sender, EventArgs e)
        {
            string title = txtTitle.Text;
            string desc = txtDesc.Text.Replace("\r\n",@"\n");
            string[] tag = txtTags.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            string partTitle = txtPartTitle.Text;
            bool allowUserAddTag = chkAllow.Checked;
            bool allowUploadBoomFun = chkBoomFun.Checked;
            int videoType = rbtnType1.Checked ? 3 : 1;
            int channelId = cboChannelSub.SelectedIndex == -1 ? 0 : Convert.ToInt32(Utils.getSubstr(cboChannelSub.SelectedItem.ToString(), "【", "】"));
            Image img = picCover.Image;
            if (title == "" || desc == "" || tag.Length ==0 || partTitle == "" || channelId==0 || img==null)
            {
                MessageBox.Show("请填写所有信息后再次提交", "错误");
                return;
            }
            if(title.Length>50 || desc.Length>255)
            {
                MessageBox.Show("标题或内容超长", "错误");
                return;
            }
            if (tag.Length>10)
            {
                MessageBox.Show("Tag最多10个", "错误");
                return;
            }
            
        }
        void uploadThread()
        {
            string title = txtTitle.Text;
            string desc = txtDesc.Text.Replace("\r\n", @"\n");
            string[] tag = txtTags.Text.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            string partTitle = txtPartTitle.Text;
            bool allowUserAddTag = chkAllow.Checked;
            bool allowUploadBoomFun = chkBoomFun.Checked;
            int videoType = rbtnType1.Checked ? 3 : 1;
            int channelId = cboChannelSub.SelectedIndex == -1 ? 0 : Convert.ToInt32(Utils.getSubstr(cboChannelSub.SelectedItem.ToString(), "【", "】"));
            Image img = picCover.Image;

        }
    }
}
